<template>
  <div class="donations-container">
    <el-card>
      <template #header>
        <div class="card-header">
          <h3>我的捐赠记录</h3>
        </div>
      </template>
      <el-table :data="donationList" style="width: 100%">
        <el-table-column prop="projectName" label="项目名称" />
        <el-table-column prop="amount" label="捐赠金额">
          <template #default="{ row }">
            ¥{{ row.amount }}
          </template>
        </el-table-column>
        <el-table-column prop="date" label="捐赠日期" />
        <el-table-column prop="status" label="状态">
          <template #default="{ row }">
            <el-tag type="success">{{ row.status }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120">
          <template #default="{ row }">
            <el-button type="primary" link @click="handleViewDetail(row.projectId)">查看项目</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 模拟数据
const donationList = ref([
  {
    id: 1,
    projectId: 1,
    projectName: '山区儿童助学计划',
    amount: '1,000',
    date: '2023-05-20',
    status: '已完成'
  },
  {
    id: 2,
    projectId: 2,
    projectName: '老年人关爱项目',
    amount: '500',
    date: '2023-05-15',
    status: '已完成'
  }
])

const handleViewDetail = (projectId: number) => {
  router.push(`/projects/${projectId}`)
}
</script>

<style lang="scss" scoped>
.donations-container {
  .card-header {
    h3 {
      margin: 0;
      color: #303133;
    }
  }
}
</style>